package com.loan.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.loan.entity.Product;
import com.loan.mappers.ProductMapper;
import com.loan.service.ProductService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author fengbenpeng
 * @Desctiption 实现类
 * @date 2022/1/18 15:10
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public void addProduct(Product product) {
       productMapper.insert(product);

    }

    @Override
    public void deleteProduct(int id) {

        productMapper.deleteById(id);
    }

    @Override
    public void updateProduct(Product product) {
        productMapper.updateById(product);
    }

    @Override
    public List<Product> getAllProduct() {
        //创建queryWrapper对象
        QueryWrapper<Product> queryWrapper = new QueryWrapper<>();
        return productMapper.selectList(queryWrapper);

    }


}
